
wd='/home/jc148322/Tammy/image_comparisons/';dir.create(wd); setwd(wd)
target.dir='/home/jc148322/Tammy/Target_bkgd/models/'
random.dir='/home/jc148322/Tammy/Random_bkgd/models/'
zlim=c(0,1)
cols=colorRampPalette(c('tan','forestgreen'))(100)
species=list.files(target.dir)

for (spp in species) {

	random=read.asc.gz(paste(random.dir,spp,'/output/ascii_WTcurrent/curent.asc.gz',sep=''))
	target=read.asc.gz(paste(target.dir,spp,'/output/ascii_WTcurrent/curent.asc.gz',sep=''))
	occur=read.csv(paste(target.dir,spp,'/occur.csv',sep=''))
	png(paste(spp,'.comparison.png',sep=''),width=dim(random)[1]*2+20, height=dim(random)[2]*1+20, units='px', pointsize=20, bg='white')
	par(mar=c(3,3,3,2),mfrow=c(1,2),cex=1,oma=c(3,0,1,0))
	image(random, ann=FALSE,axes=FALSE,col=cols, zlim=zlim)
	points(occur[,3],occur[,2],pch=16,col='black')
	mtext('Random', line=2,  side=1, cex=1.5)

	image(target, ann=FALSE,axes=FALSE,col=cols, zlim=zlim)
	points(occur[,3],occur[,2],pch=16,col='black')
	mtext('Target', line=2,  side=1, cex=1.5)
	dev.off()


}
